//
//  AXFProductTableViewCell.m
//  AXFEightGroup
//
//  Created by ya on 12/23/16.
//  Copyright © 2016 ya. All rights reserved.
//

#import "AXFProductTableViewCell.h"
#import "AXFShoppingButtonView.h"
#import "AXFDataModel.h"

@interface AXFProductTableViewCell ()

@property (weak, nonatomic) IBOutlet UILabel *nameLabel;
@property (weak, nonatomic) IBOutlet UILabel *specificsLabel;
@property (weak, nonatomic) IBOutlet UILabel *partner_priceLabel;
@property (weak, nonatomic) IBOutlet UILabel *market_priceLabel;
@property (weak, nonatomic) IBOutlet UIImageView *pm_descImageView;
@property (nonatomic, strong) AXFShoppingButtonView *shoppingButtonView;

@end

@implementation AXFProductTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    self.selectionStyle = UITableViewCellSelectionStyleNone;

    [self setShoppingButtonView:nibView(@"AXFShoppingButtonView")];
    [self.contentView addSubview:self.shoppingButtonView];

    CGFloat space = 8.0;
    [self.shoppingButtonView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.contentView);
        make.bottom.equalTo(self.contentView).offset(-space);
    }];
}

/// pm_desc 如果有值, 显示 买一赠送 图片

- (void)setModel:(AXFDataModel *)model {
    _model = model;
    /// nearby_food
    [self.imgImageView sd_setImageWithURL:[NSURL URLWithString:model.img] placeholderImage:Image(@"nearby_food")];
    self.nameLabel.text             = model.name;
    self.specificsLabel.text        = model.specifics;
    self.partner_priceLabel.text    = [NSString stringWithFormat:@"$%@", model.partner_price];
    self.pm_descImageView.hidden    = (model.pm_desc.length > 0) ? NO : YES;

    self.shoppingButtonView.model   = model;



    /// 画删除线
    NSDictionary *attribtDic = @{NSStrikethroughStyleAttributeName: [NSNumber numberWithInteger:NSUnderlineStyleSingle]};
    NSMutableAttributedString *attribtStr = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"$%@",model.market_price] attributes:attribtDic];
    [self.market_priceLabel setAttributedText:attribtStr];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}


@end
